﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HikVisionTool.Helper
{
    public class Sql2Helper
    {
        private ConnectionConfig connection = null;
        public SqlSugarClient db = null;
        public Sql2Helper()
        {
            string SqlIP = "192.168.2.2";
            string database = "MESDB";
            string uid = "sa";
            string pwd = "8ik,9ol.";
            connection = new ConnectionConfig()
            {
                ConnectionString = "server='" + SqlIP + "';initial catalog='" + database + "';uid='" + uid + "';pwd='" + pwd + "'",
                DbType = DbType.SqlServer,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            };
            db = new SqlSugarClient(connection);
        }
        public bool SqlCheck()
        {
            try
            {
                db.Open();
                db.Close();
                db.Dispose();
                return true;
            }
            catch (Exception ee)
            {
                return false;
            }
        }


        #region t_Item
        [SugarTable("t_Item")]
        public class t_Item
        {
            public int id { get; set; }
            public string itemName { get; set; }
            public int pid { get; set; }
            public int id_itemType { get; set; }
            public int displayOrder { get; set; }
        }
        #endregion

        #region hkwsAll
        [SugarTable("hkwsAll")]
        public class hkwsAll
        {
            public string line { get; set; }
            public string code1 { get; set; }
            public string name1 { get; set; }
            public string time1 { get; set; }
            public int Fst { get; set; }
            public string codewrong { get; set; }
            public string timewrong { get; set; }
            public string code2 { get; set; }
            public string name2 { get; set; }
            public string time2 { get; set; }
            public int Sec { get; set; }
            public string code3 { get; set; }
            public string name3 { get; set; }
            public string time3 { get; set; }
            public int thd { get; set; }
            public string code4 { get; set; }
            public string name4 { get; set; }
            public string time4 { get; set; }
            public int fth { get; set; }
            public string Res { get; set; }
            public string code22 { get; set; }
            public string name22 { get; set; }
            public string time22 { get; set; }
            public int Sechalf { get; set; }
            public string band { get; set; }
            public string result3 { get; set; }
            public string result4
            {
                get; set;
            }
        }
        #endregion

        #region Order_Match
        [SugarTable("Order_Match")]
        public class Order_Match
        {
            public string prodBarCode { get; set; }
            public string order_code { get; set; }
            public string Line_No { get; set; }
            public DateTime createTime { get; set; }
        }
        #endregion

        #region t_proc_plan_main
        [SugarTable("t_proc_plan_main")]
        public class t_proc_plan_main
        {
            public int id { get; set; }
            public string standard { get; set; }
            public string order_code { get; set; }
            public string mo_code { get; set; }
            public int order_count { get; set; }
        }
        #endregion


        #region hkws
        [SugarTable("hkws")]
        public class hkws
        {
            public string MoCode { get; set; }
            public int id_wo { get; set; }
            public string plcode { get; set; }
            public int Jiwei { get; set; }
            public string Gongwei { get; set; }
            [SugarColumn(IsPrimaryKey = true)]
            public string prodBarCode { get; set; }
            public int Result { get; set; }
            public string ProduceModel { get; set; }
            public DateTime createTime { get; set; }
            public string Resultinfo { get; set; }
            public int Flag { get; set; }
        }
        #endregion

        #region t_proc_plan_detail
        [SugarTable("t_proc_plan_detail")]
        public class t_proc_plan_detail
        {
            [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
            public long id { get; set; }
            public int id_main { get; set; }
            public int type_plan { get; set; }
            public string plandate { get; set; }
            public int type_produce { get; set; }
            public int count { get; set; }
        }
        #endregion

        #region t_DD_UserDetail
        [SugarTable("t_DD_UserDetail")]
        public class t_DD_UserDetail
        {
            public string username { get; set; }
            public string jobnumber { get; set; }
            public string companyName { get; set; }
        }
        #endregion
    }
}

